package Adaper;

/**
 * Created by 0171093 on 2018/2/7.
 */
public class MultiplyAdapter extends Adder implements IMultiplyService {
    @Override
    public int multiply(int a, int b) {

        int sum = 0;
        for (int i = 0; i < b; i++) {
            sum = add(sum, a);//通过加法功能去代替乘法实现
        }
        if (b < 0) {
            sum = -sum;
        }
        return sum;
    }
}
